<template>
  <div>
    <eagle-dialog-page
      :isMulti="true"
      :url="url"
      :option="option"
      :params="params"
      :title="title"
      @initList="_initList"
      @open="open"
      @submit="submit"
      @callbackDialog="callbackDialog"
      @setData="setData"
      @initActive="initActive"
      v-bind="$attrs"
      v-on="$listeners"
      tab
      isOpenNew
      ref="eagleDialogPage"
    >
      <template v-if="tabActive == 0">
        <div class="list">
          <van-row :gutter="20" type="flex">
            <van-col
              span="8"
              v-for="(item, index) in list"
              :key="index"
              type="flex"
              class="list-item"
            >
              <van-col span="24" class="colstyle" type="flex">
                <div style="display: table-caption">
                  <van-image
                    class="ml-10 image-box-shadow"
                    width="50"
                    height="50"
                    fit="MarkAttach"
                    :src="(item.MarkAttach&&item.MarkAttach.includes('http'))?item.MarkAttach:(baseUrl + item.MarkAttach)"
                  />
                </div>
                <div class="mb-5 mt-10" type="flex" style="line-height: 1.3">
                  {{ item.MarkName }}
                </div>
                <div>
                  <van-checkbox :name="item.MarkCode" />
                </div>
              </van-col>
            </van-col>
          </van-row>
        </div>
      </template>
      <template v-else>
        <div class="list">
          <van-row :gutter="20" type="flex">
            <van-col
              span="8"
              v-for="(item, index) in list"
              :key="index"
              type="flex"
              class="list-item"
            >
              <van-col span="24" class="colstyle" type="flex">
                <div style="display: table-caption">
                  <van-image
                    class="ml-10 image-box-shadow"
                    width="50"
                    height="50"
                    fit="MarkAttach"
                    :src="baseUrl + item.MarkAttach"
                  />
                </div>
                <div class="mb-5 mt-10" type="flex" style="line-height: 1.3">
                  {{ item.MarkName }}
                </div>
                <div>
                  <van-checkbox :name="item.MarkCode" />
                </div>
              </van-col>
            </van-col>
          </van-row>
        </div>
      </template>
    </eagle-dialog-page>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
export default {
  name: "eagle-risk-mark",
  props: {
    url: {
      type: String,
      default: "/RiskMark/GetRiskMarkPageData",
    },
    title: {
      type: String,
      default: "选择标识",
    },
    confirmButton: {
      type: String,
      default: "确认",
    },
    tagData: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      option: { name: "MarkName", code: "MarkCode" },
      list: [],
      params: [
        {
          title:"益戈标识库",
          dataType: "Sys",
          PageType: "OpRegulation",
        },
        {
          title:"公司标识库",
          dataType: "Company",
          PageType: "OpRegulation",
        },
      ],
      tabActive: 0,
      selectedlist: [],
    };
  },
  computed: {
    ...mapGetters(["baseUrl"]),
  },
  methods: {
    initActive(active) {
      this.tabActive = active;
    },
    _initList(list) {
      this.selectedlist = this.tagData;
      this.list = list;
    },
    open(list) {
      this.listUser = list;
    },
    submit() {
      this.$refs.eagleDialogPage.submit();
    },
    setData(data) {
      
      this.selectedlist = data;
    },
    callbackDialog(data) {
      this.$emit("callback", this.selectedlist);
      this.$emit("update:show", false);
    },
  },
};
</script>
<style lang="less" scoped>
.risk {
  height: 100vh;
  background-color: #e8f1f8;

  .info_search {
    padding: 10px;
    border-radius: 5px !important;

    .van-field__control {
      background-color: #ffffff !important;
    }
  }
}
.list {
  padding: 10px;
  background-color: #ffffff;
  .list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    background-color: #fff;
    padding: 20px 10px;
    font-size: 14px;
    border-radius: 8px;
    .list-item-l {
      display: flex;
      align-items: center;
    }
  }
}
.colstyle {
  margin-bottom: 5px;
}
</style>